package Controller;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import junit.framework.TestCase;

import java.util.ArrayList;
import Catalog.Book;
import Catalog.BookList;
import User.Guest;
import VO.BookListVO;
import VO.BookVO;
import VO.GuestVO;

public class EnshrineIntegrationTester extends TestCase{
	private EnshrineController controller;

	@Before
	protected void setUp() throws Exception {
		super.setUp();
		controller=new EnshrineController(0);
	}

	@After
	protected void tearDown() throws Exception {
		super.tearDown();
	}

	@Test
	public void testEnshrine() {
		GuestVO guest=controller.enshrine(0);
		BookListVO booklist=guest.getEnshrineList();
		ArrayList<BookVO> books=booklist.getBooklist();
		int size=books.size();
		assertEquals(books.get(size-1).getID(),0);
	}

	@Test
	public void testDeletsEnshrine() {
		Guest guest=controller.guest;
		BookList booklist=guest.getEnshrineList();
		ArrayList<Book> books=booklist.getBookList();
		long id=books.get(0).getID();
		
		GuestVO guestVO=controller.deletsEnshrine(0);
		BookListVO booklistVO=guestVO.getEnshrineList();
		ArrayList<BookVO> booksVO=booklistVO.getBooklist();
		boolean isExisted=false;
		
		for(int i=0;i<booksVO.size();i++){
			if(booksVO.get(i).getID()==id){
				isExisted=true;
				break;
			}
		}
		
		assertEquals(isExisted,false);
	}

}
